home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 5.0 KB | 168 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: TextPart.h
- // Release Version: $ 1.0d1 $
- //
- // Author: Anthone Burbidge
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef _TEXTPART_
- #define _TEXTPART_
-
- #ifndef _TEXTDEF_
- #include "TextDef.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPARTING_H
- #include "FWParting.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _STORAGEU_
- #include "StorageU.h"
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- class FW_CFrame;
- class XMPSemanticInterface;
- class __machdl COpenDocText;
- class CTextFrame;
- class CTextFacet;
- class FW_CSelection;
- class CTextSelection;
-
-
- //========================================================================================
- // CTextPart
- //========================================================================================
-
- class CTextPart : public FW_CEmbeddingPart
- {
- friend CTextSelection;
-
- // ----- Types
- public:
- typedef char Justification;
-
- // ----- Constants
- public:
- enum { kFontMenu = 5, kSizeMenu = 6, kEmbedMenu = 7 };
- enum { kRootFrameId = 'root', kContentFrameId = 'cont', kRulerFrameId = 'rulr' };
- enum { kNumberOfTools = 4 };
- enum { kMarginPictHeight = 9, kMarginPictWidth = 5 };
- enum { kToolHeights = 13, kToolWidths = 19 };
- enum { kRulerHeight = 16, kRulerWidth = 614 };
- enum { kRulerRulerHeight = 20, kRulerToolsHeight = kToolHeights + 9 };
-
- private:
- static const XMPPropertyName kTextPropertyName;
- static const XMPValueType kTextensionTextType;
-
- // ----- Initialization and termination
- public:
- CTextPart();
- virtual ~ CDECL CTextPart();
-
- virtual void Initialize();
-
- // ----- from FW_CEmbeddingPart
- public:
- virtual void Draw(XMPFacet* xmpFacet, XMPShape* invalidShape);
- // virtual FW_CFrame* NewScrollerFrameTree(XMPFrame* xmpFrame);
- virtual FW_CFrame* NewFrame(XMPFrame* xmpFrame, XMPTypeToken presentation);
- virtual FW_CSelection* NewSelection();
- virtual void InternalizeContent(XMPStorageUnit* storageUnit);
- virtual void ExternalizeContent(XMPStorageUnit* storageUnit);
- virtual void DoAdjustMenus(XMPMenuBar* menuBar);
- virtual FW_Boolean DoMenuEvent(XMPMenuBar *menuBar, XMPCommandID commandID);
- virtual XMPValueType GetContentPropertyValueType() const;
- virtual FW_CProxyRun* NewProxyRun();
- virtual XMPTypeToken GetDefaultPresentation() const;
-
-
- // ----- New Methods
- public:
- COpenDocText* GetEditText()
- { return fEditText; }
-
- // The following methods apply to the current selection.
- virtual void SetFontSize(short fontSize);
- virtual Boolean GetFontSize(short& fontSize) const;
- virtual void SetFont(const Str255 fontName);
- virtual Boolean GetFont(Str255 fontName) const;
- virtual void SetSelectionJustification(Justification justify) const;
- virtual Justification GetSelectionJustification() const;
- CTextFacet* GetAnyFacet(XMPTypeToken presentation = 0);
-
-
- void HandleEmbedMenuEvent(short item);
- void HandleEmbedPart(XMPPart* xmpPart, const FW_CRect& frameShape);
-
- XMPTypeToken GetMainPresentation() const
- { return fMainPresentation; }
- XMPTypeToken GetRulerPresentation() const
- { return fRulerPresentation; }
-
- Boolean IsDrawing()
- { return fIsDrawing; }
- void SetEmbeddedRunFrame(CTextFrame *frame)
- { fEmbeddedRunFrame = frame; }
- CTextFrame* GetEmbeddedRunFrame()
- { return fEmbeddedRunFrame; }
- void SetEmbeddedRunFacet(CTextFacet *facet)
- { fEmbeddedRunFacet = facet; }
- CTextFacet* GetEmbeddedRunFacet()
- { return fEmbeddedRunFacet; }
- void SetEmbeddedRunEvent(XMPEventData event)
- { fEvent = event; }
- XMPEventData GetEmbeddedRunEvent()
- { return fEvent; }
- static CTextPart* GetCurrentPart()
- { return gCurrentPart; }
-
- private:
- static void InitializeTextension();
-
- void CreateEditText();
- void StuffInTheText(FW_PlatformHandle text, Size textSize);
- void StuffInTheStyles(FW_PlatformHandle styles, Size stylesSize);
-
- // ----- Data Members
- private:
- MenuHandle fFontMenu;
- MenuHandle fSizeMenu;
- MenuHandle fEmbedMenu;
-
- XMPTypeToken fRulerPresentation;
- XMPTypeToken fMainPresentation;
- XMPTypeToken fScrollerPresentation;
-
- COpenDocText* fEditText;
-
- // Hack. When my Textension run object's draw method is called by Textension I need to
- // be able to pass it some parameters. I store those parameters here before calling methods
- // on Textension.
-
- Boolean fIsDrawing;
- CTextFrame *fEmbeddedRunFrame;
- CTextFacet *fEmbeddedRunFacet;
- XMPEventData fEvent;
-
- // Global variable used to pass current part through to Textension during
- // internalization and cloning.
-
- static CTextPart* gCurrentPart;
- };
-
- #endif
-